<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring AOP 切面编程完全指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        
        .text-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        
        .code-block {
            background: #1e1e1e;
            border-radius: 12px;
            overflow: hidden;
        }
        
        .code-header {
            background: #2d2d2d;
            padding: 10px 20px;
            font-size: 14px;
            color: #888;
        }
        
        pre {
            margin: 0;
            padding: 20px;
            overflow-x: auto;
        }
        
        code {
            font-family: 'Consolas', 'Monaco', monospace;
            color: #d4d4d4;
            line-height: 1.6;
        }
        
        .section-divider {
            height: 2px;
            background: linear-gradient(to right, transparent, #667eea, transparent);
            margin: 60px 0;
        }
        
        .feature-icon {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 16px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            font-size: 24px;
            margin-bottom: 20px;
        }
        
        .timeline-item {
            position: relative;
            padding-left: 40px;
            margin-bottom: 30px;
        }
        
        .timeline-item::before {
            content: '';
            position: absolute;
            left: 0;
            top: 8px;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: #667eea;
            box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
        }
        
        .timeline-item::after {
            content: '';
            position: absolute;
            left: 7px;
            top: 24px;
            width: 2px;
            height: calc(100% + 14px);
            background: #e5e7eb;
        }
        
        .timeline-item:last-child::after {
            display: none;
        }
        
        .drop-cap {
            float: left;
            font-size: 4em;
            line-height: 0.8;
            margin: 0.1em 0.1em 0 0;
            font-weight: 700;
            color: #667eea;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 40px 0;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6">
                    Spring AOP 切面编程
                </h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90">
                    掌握面向切面编程的艺术，优雅地处理横切关注点
                </p>
                <div class="flex justify-center space-x-6 text-lg">
                    <div class="flex items-center">
                        <i class="fas fa-layer-group mr-2"></i>
                        <span>模块化设计</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-code-branch mr-2"></i>
                        <span>关注点分离</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-sync-alt mr-2"></i>
                        <span>代码复用</span>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12">
        <!-- Introduction -->
        <section class="max-w-4xl mx-auto mb-16">
            <div class="bg-white rounded-2xl shadow-xl p-8 md:p-12">
                <p class="text-lg leading-relaxed text-gray-700">
                    <span class="drop-cap">在</span>Spring框架中，切面（Aspect）是面向切面编程（Aspect-Oriented Programming，AOP）的核心概念之一。切面用于定义跨越多个类的关注点或逻辑，常用于处理日志记录、事务管理、安全控制等功能。Spring AOP允许开发者将这些关注点与业务逻辑分离，从而提高代码的模块化和可维护性。
                </p>
            </div>
        </section>

        <!-- Core Concepts -->
        <section class="max-w-6xl mx-auto mb-16">
            <h2 class="text-4xl font-bold text-center mb-12 text-gradient">核心概念解析</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-2xl shadow-lg p-8 card-hover">
                    <div class="feature-icon">
                        <i class="fas fa-bullseye"></i>
                    </div>
                    <h3 class="text-2xl font-bold mb-4">切面的定义</h3>
                    <p class="text-gray-700 leading-relaxed">
                        <strong>切面（Aspect）</strong>是一种模块化的关注点，它将横切关注点（cross-cutting concerns）集中在一个模块中。横切关注点指的是在多个模块中都需要处理的功能，例如事务管理、日志记录等。切面通过定义通知（Advice）和切入点（Pointcut）来实现对这些横切关注点的处理。
                    </p>
                </div>
                
                <div class="bg-white rounded-2xl shadow-lg p-8 card-hover">
                    <div class="feature-icon">
                        <i class="fas fa-puzzle-piece"></i>
                    </div>
                    <h3 class="text-2xl font-bold mb-4">切面的组成部分</h3>
                    <p class="text-gray-700 leading-relaxed">
                        切面通常包括通知（Advice）、切入点（Pointcut）、连接点（Joinpoint）和目标对象（Target Object）等核心组件，它们协同工作，实现对横切关注点的统一管理。
                    </p>
                </div>
            </div>
        </section>

        <!-- Components Visualization -->
        <section class="max-w-6xl mx-auto mb-16">
            <div class="bg-white rounded-2xl shadow-xl p-8 md:p-12">
                <h2 class="text-3xl font-bold mb-8 text-center">AOP 组件关系图</h2>
                <div class="mermaid">
                    graph TD
                        A[切面 Aspect] --> B[通知 Advice]
                        A --> C[切入点 Pointcut]
                        C --> D[连接点 Joinpoint]
                        B --> E[前置通知 Before]
                        B --> F[后置通知 After]
                        B --> G[环绕通知 Around]
                        B --> H[异常通知 Throwing]
                        D --> I[目标对象 Target]
                        
                        style A fill:#667eea,stroke:#fff,stroke-width:2px,color:#fff
                        style B fill:#764ba2,stroke:#fff,stroke-width:2px,color:#fff
                        style C fill:#764ba2,stroke:#fff,stroke-width:2px,color:#fff
                        style D fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                        style I fill:#b794f4,stroke:#fff,stroke-width:2px,color:#fff
                </div>
            </div>
        </section>

        <!-- Advice Types -->
        <section class="max-w-6xl mx-auto mb-16">
            <h2 class="text-4xl font-bold text-center mb-12">通知类型详解</h2>
            
            <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
                <div class="bg-gradient-to-br from-purple-50 to-indigo-50 rounded-xl p-6 card-hover">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-play-circle text-3xl text-purple-600 mr-4"></i>
                        <h4 class="text-xl font-bold">前置通知</h4>
                    </div>
                    <p class="text-gray-700">在目标方法执行之前执行的通知，常用于权限验证、参数校验等场景。</p>
                </div>
                
                <div class="bg-gradient-to-br from-blue-50 to-cyan-50 rounded-xl p-6 card-hover">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-check-circle text-3xl text-blue-600 mr-4"></i>
                        <h4 class="text-xl font-bold">后置返回通知</h4>
                    </div>
                    <p class="text-gray-700">目标方法成功执行后执行的通知，可以获取方法的返回值。</p>
                </div>
                
                <div class="bg-gradient-to-br from-red-50 to-pink-50 rounded-xl p-6 card-hover">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-exclamation-circle text-3xl text-red-600 mr-4"></i>
                        <h4 class="text-xl font-bold">后置异常通知</h4>
                    </div>
                    <p class="text-gray-700">目标方法抛出异常后执行的通知，用于异常处理和日志记录。</p>
                </div>
                
                <div class="bg-gradient-to-br from-green-50 to-emerald-50 rounded-xl p-6 card-hover">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-sync-alt text-3xl text-green-600 mr-4"></i>
                        <h4 class="text-xl font-bold">环绕通知</h4>
                    </div>
                    <p class="text-gray-700">在目标方法执行前后都执行，可以控制方法是否执行。</p>
                </div>
                
                <div class="bg-gradient-to-br from-yellow-50 to-amber-50 rounded-xl p-6 card-hover">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-stop-circle text-3xl text-yellow-600 mr-4"></i>
                        <h4 class="text-xl font-bold">最终通知</h4>
                    </div>
                    <p class="text-gray-700">无论方法是否抛出异常都会执行，类似于finally块。</p>
                </div>
                
                <div class="bg-gradient-to-br from-indigo-50 to-purple-50 rounded-xl p-6 card-hover">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-plus-circle text-3xl text-indigo-600 mr-4"></i>
                        <h4 class="text-xl font-bold">引导通知</h4>
                    </div>
                    <p class="text-gray-700">为目标对象引入新的方法或属性，实现接口的动态实现。</p>
                </div>
            </div>
        </section>

        <div class="section-divider"></div>

        <!-- Implementation Example -->
        <section class="max-w-6xl mx-auto mb-16">
            <h2 class="text-4xl font-bold text-center mb-12">切面实现示例</h2>
            
            <div class="space-y-8">
                <!-- Step 1 -->
                <div class="bg-white rounded-2xl shadow-lg overflow-hidden">
                    <div class="bg-gradient-to-r from-purple-600 to-indigo-600 text-white p-6">
                        <h3 class="text-2xl font-bold flex items-center">
                            <i class="fas fa-code mr-3"></i>
                            步骤 1：定义切面类
                        </h3>
                    </div>
                    <div class="p-8">
                        <p class="text-gray-700 mb-6">使用@Aspect注解定义切面类，并在其中编写通知方法：</p>
                        <div class="code-block">
                            <div class="code-header">
                                <i class="fas fa-file-code mr-2"></i>LoggingAspect.java